package com.hn.gege.sys.modules.sys.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.hn.gege.sys.modules.sys.entity.AreaDict;
import com.hn.gege.sys.modules.sys.service.IAreaDictService;
import com.hn.gege.core.common.CommonResult;
import com.hn.gege.core.common.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.constraints.NotBlank;
import java.util.List;


@Api(tags = "SysAreaDictController", description = "管理")
@RestController
@RequestMapping("/sys/sys-area-dict")
@Validated
public class AreaDictController extends BaseController {

    @Autowired
    IAreaDictService areaDictService;


    @ApiOperation("查询地区字典列表")
    @ApiImplicitParam(name="upperRegion",value="上级地区代码(没有上级传0)",required=true,dataType="String",paramType="query")
    @GetMapping(value="/arealist")
    public CommonResult<List<AreaDict>> getAreaList(@NotBlank String upperRegion) {
        LambdaQueryWrapper<AreaDict> eq = new QueryWrapper<AreaDict>().lambda()
                .eq(AreaDict::getUpperRegion, upperRegion);
        List<AreaDict> list = areaDictService.list(eq);
        return CommonResult.success(list);
    }


}
